<template>
	<view class="realInfo">
		<view class="form p30">
			<view class="formItem">
				<view class="lable">用户头像</view>
				<view class="p20 uerImg">
					<image :src="item.avatar" mode="aspectFill"></image>
				</view>
			</view>
			<view class="formItem">
				<view class="lable">用户真实姓名</view>
				<view class="value p20">{{ item.realName }}</view>
			</view>
			<view class="formItem">
				<view class="lable">用户学号</view>
				<view class="value p20">{{ item.studentNo }}</view>
			</view>
			<view class="formItem">
				<view class="lable">用户学生证照片</view>
				<view class="upImg">
					<image :src="item.credential" mode="aspectFill"></image>
				</view>
			</view>
		</view>
		<view class="butDom dis" v-if="item.auditStatus == 0">
			<view class="but primaryBut" @click.stop="approve(item.id)">通过</view>
			<view class="but errBut" @click.stop="rejectFun(item.id)">驳回</view>
		</view>
	</view>
	<up-modal title="驳回理由" :show="showModal" contentTextAlign="center" confirmButtonShape="circle">
		<view class="slot_content">
			<up-input placeholder="请输入驳回理由" border="surround" v-model="reject"></up-input>
		</view>
		<template #confirmButton>
			<view class="modalBut dis">
				<view class="custom_btn nodeBut" @click="okDel">取消</view>
				<view class="custom_btn" @click="okAdd">确定</view>
			</view>
		</template>
	</up-modal>
</template>

<script setup>
import { userIdentity, approvedSubmit } from '@/config/api.js';
import { ref } from 'vue';
import { onShow, onLoad, onReachBottom } from '@dcloudio/uni-app';
const item = ref(0);
onLoad((options) => {
	const items = options.item;
	if (items) {
		item.value = JSON.parse(items);
		console.log(item.value);
	}
});
const showModal = ref(false);
const userId = ref(0);
const reject = ref('');
// 审核通过
const approve = (id) => {
	reject.value = '';
	userId.value = id;
	submit(1);
};
// 审核驳回
const rejectFun = (id) => {
	reject.value = '';
	userId.value = id;
	showModal.value = true;
};
const okDel = () => {
	reject.value = '';
	userId.value = 0;
	showModal.value = false;
};
const okAdd = () => {
	submit(2);
};
const submit = async (num) => {
	if (showModal.value && reject.value == '') {
		uni.showToast({
			title: '请输入驳回理由',
			icon: 'none'
		});
		return;
	}
	const data = {
		auditStatus: num,
		rejectReason: reject.value
	};
	const res = await approvedSubmit(userId.value, data);
	console.log(res);
	if (res.code == 0) {
		item.value = [];
		uni.navigateBack({
			delta: 1
		});
	}
};
</script>

<style scoped lang="scss">
.realInfo {
	padding-bottom: 110rpx;
	width: 100%;
	.form {
		width: 100%;
		.formItem {
			padding-bottom: 20rpx;
			font-size: 26rpx;
			.lable {
				margin-bottom: 20rpx;
				color: #a7a6ab;
			}
			.uerImg {
				width: 90rpx;
				height: 90rpx;
				border-radius: 15rpx;
				background-color: #ccc;
				overflow: hidden;
			}
			.value {
				background-color: #f3f3f5;
			}
			.upImg {
				width: 100%;
				height: 220rpx;
				border-radius: 15rpx;
				background-color: #ccc;
				overflow: hidden;
			}
		}
	}
	.butDom {
		position: fixed;
		bottom: 0rpx;
		left: 0rpx;
		justify-content: space-around;
		align-items: center;
		padding: 20rpx 0;
		width: 100%;
		background-color: #ccc;
		.but {
			width: 20%;
			line-height: 55rpx;
			font-size: 24rpx;
			border-radius: 27.5rpx;
			text-align: center;
		}
	}
}
.slot_content {
	width: 100%;
}
.modalBut {
	align-items: center;
	justify-content: space-around;
	width: 100%;
	.custom_btn {
		width: 40%;
		height: 70rpx;
		line-height: 70rpx;
		border-radius: 35rpx;
		text-align: center;
		color: #fff;
		background-color: #3391e6;
	}
	.nodeBut {
		color: #515151;
		background-color: #f0f0f0;
	}
}
</style>
<style>
page {
	background-color: #f7f7f7;
}
image {
	width: 100%;
	height: 100%;
}
.card {
	margin-bottom: 20rpx;
	background-color: #fff;
	border-radius: 15rpx;
}
.noData {
	width: 100%;
	line-height: 90rpx;
	color: #999;
	text-align: center;
	background-color: #f7f7f7;
}
</style>
